package com.project.weimi.fragment;

import org.xutils.x;

import com.project.weimi.application.Constant;
import com.project.weimi.utils.NetUtils;
import com.project.weimi.utils.SharedPreferencesHelper;
import com.project.weimi.widget.ToastMessage;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;

public class BaseFragment extends Fragment{

	public SharedPreferencesHelper spHelper;
	public String memberId;
	public String baseNickName;
	public String baseSex;
	public String baseAge;
	public String baseAddress;
	public String baseSign;
	public String baseHeadImgPath;
	public String integrate;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		x.view().inject(getActivity());
		// 检查网络状态
		if(!NetUtils.isConnected(getActivity())){
			ToastMessage.showToast(getActivity(), "网络不给力，请检查网络设置");
		}

		spHelper = new SharedPreferencesHelper(getActivity(), Constant.USER_INFO);
		if(null != spHelper){
			memberId = (String) spHelper.get("memberId", "");
			//Log.e("TAG", "onCreate===BaseActivity---"+memberId);
			baseNickName = (String) spHelper.get("nickName", "");
			baseSex = (String) spHelper.get("sex", "");
			baseAge = (String) spHelper.get("age", "");
			baseSign = (String) spHelper.get("sign", "");
			baseAddress = (String) spHelper.get("address", "");
			baseHeadImgPath = (String) spHelper.get("headImgPath", "");
			integrate = (String) spHelper.get("integrate", ""); 
		} else {
			spHelper = null;
			memberId = "";
			baseNickName = "";
			baseSex = "";
			baseAge = "";
			baseSign = "";
			baseAddress = "";
			baseHeadImgPath = "";
			integrate = "";
		}
		
	}
	
	@Override
	public void onStart() {
		super.onStart();
	}
	
	@Override
	public void onResume() {
		super.onResume();
		spHelper = new SharedPreferencesHelper(getActivity(), Constant.USER_INFO);
		if(null != spHelper){
			memberId = (String) spHelper.get("memberId", "");
			//Log.e("TAG", "onCreate===BaseActivity---"+memberId);
			baseNickName = (String) spHelper.get("nickName", "");
			baseSex = (String) spHelper.get("sex", "");
			baseAge = (String) spHelper.get("age", "");
			baseSign = (String) spHelper.get("sign", "");
			baseAddress = (String) spHelper.get("address", "");
			baseHeadImgPath = (String) spHelper.get("headImgPath", "");
			integrate = (String) spHelper.get("integrate", ""); 
		} else {
			spHelper = null;
			memberId = "";
			baseNickName = "";
			baseSex = "";
			baseAge = "";
			baseSign = "";
			baseAddress = "";
			baseHeadImgPath = "";
			integrate = "";
		}
	}
	
	@Override
	public void onPause() {
		super.onPause();
	}
	
	
}
